﻿Imports KanBan.Pgd.Common
Imports KanBan.Pgd.Presentation.Controllers
Imports KanBan.Pgd.Infrastructure.Repositories
Imports KanBan.Pgd.Domain.Entities
Imports NUnit.Framework
Imports System.Transactions

<TestFixture()> _
Public Class SearchRequestTest

    Private scope As TransactionScope = Nothing

    <SetUp()> _
    Public Sub Init()
        scope = New TransactionScope()
    End Sub

    <TearDown()> _
    Public Sub Dispose()
        If Not scope Is Nothing Then
            scope.Dispose()
            scope = Nothing
        End If
    End Sub

    <Test()> _
    Public Sub AddCandidatesTest()

        Dim fakeView As New ManageSearchRequestCandidatesFake()
        fakeView.SearchRequestId = TestConstants.SearchRequestInProgressId

        Dim controller As New ManageSearchRequestCandidatesController(fakeView)

        Dim list As New List(Of Guid)()
        list.Add(TestConstants.Candidate1Id)

        controller.SaveSelectedCandidates(list)

        Dim repository As New SearchRequestRepository()
        Dim savedSearchRequest = repository.GetById(TestConstants.SearchRequestInProgressId)

        Assert.AreEqual(1, savedSearchRequest.Candidates.Count)

    End Sub

End Class
